﻿@using ChGK.Data;

@if (ViewBag.Role == "User") 
    {Layout = "~/Views/Shared/_LayoutUser.cshtml";}
 else if (ViewBag.Role == "Superuser")
    {Layout = "~/Views/Shared/_LayoutSuperuser.cshtml";}
 else
    {Layout = "~/Views/Shared/_Layout.cshtml";}


@{
    ViewBag.Title = "Турниры";
}

<h2>@ViewBag.Message</h2>
<p>
    @{int j = 0;}
    @foreach (Competition c in (IEnumerable<Competition>)ViewData["Competitions"])
    {
        if (Model[j] == 0)
        {
            <p>@c.Name - Ещё не начался.</p>
        }
        else if (Model[j] == -101)
        {
            <p>@Html.ActionLink(c.Name, "SummaryTable", new { CompetitionID = c.ID }) - Турнир завершён.</p>
        }
        else if (Model[j] == -100)
        {
            <p>@Html.ActionLink(c.Name, "SummaryTable", new { CompetitionID = c.ID }) - Подведены предварительные итоги.</p>
        }
        else if (Model[j] < 0)
        {
            <p>@Html.ActionLink(c.Name, "SummaryTable", new { CompetitionID = c.ID }) - Перерыв после @Math.Abs(Model[j]) тура.</p>
        }
        else if ((Model[j] % 10) == 1 && Model[j] != 11)
        {
            <p>@Html.ActionLink(c.Name, "SummaryTable", new { CompetitionID = c.ID }) - Сыгран @Model[j] вопрос.</p>
        }
        else if ((Model[j] % 10) >= 2 && (Model[j] % 10) <= 4 && (Model[j] < 12 || Model[j] > 14))
        {
            <p>@Html.ActionLink(c.Name, "SummaryTable", new { CompetitionID = c.ID }) - Сыграно @Model[j] вопроса.</p>
        }
        else
        {
            <p>@Html.ActionLink(c.Name, "SummaryTable", new { CompetitionID = c.ID }) - Сыграно @Model[j] вопросов.</p>
        }
        j++;        
    }
</p>
